﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ChatInterfaces;
using System.ServiceModel;

namespace CHATCLIENT
{
    [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Single, InstanceContextMode = InstanceContextMode.Single, IncludeExceptionDetailInFaults = true)]
    public class ClientService : IClientOperationsForClient
    {
        public event NewMsg newMsg;

        public ClientService() { }

        public void SendMessage(string message)
        {
            try
            {
                if (newMsg != null)
                    newMsg(message);
            }
            catch (Exception ex)
            {
                FaultContract fc = new FaultContract();
                fc.Msg = "Erro ao enviar menssagem " + ex.Message;
                throw new FaultException<FaultContract>(fc);
            }
        }
    }
}
